package com.fy.module.repo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fy.module.repo.entity.Repo;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 * 题库 Mapper 接口
 * </p>
 *
 * @author 虚拟宇宙公司
 * @since 2023-03-20
 */
public interface RepoMapper extends BaseMapper<Repo> {

    /**
     * 更新题库的单选、多选、判断等的数量
     * @return
     */
    @Update("update el_repo set " +
            "radio_count=(select count(*) from el_qu_repo where el_qu_repo.repo_id=#{repoId} and el_qu_repo.qu_type=1)," +
            "multi_count=(select count(*) from el_qu_repo where el_qu_repo.repo_id=#{repoId} and el_qu_repo.qu_type=2)," +
            "judge_count=(select count(*) from el_qu_repo where el_qu_repo.repo_id=#{repoId} and el_qu_repo.qu_type=3)," +
            "jdt_count=(select count(*) from el_qu_repo where el_qu_repo.repo_id=#{repoId} and el_qu_repo.qu_type=4) " +
            "where id = #{repoId}")
    int updateRepoQuCount(String repoId);
}
